<?php
  session_start();
  header("content-type=textml; charset=utf-8");  //设置字符集
  require("config.php");  //包含数据库连接文件
  $username  = $_POST['username']; //获取用户姓名
  $password  = $_POST['password'];  //获取密码
  
  //判断用户名密码是否为空
  if($username== NULL || $password== NULL)
  {
	 echo "<script>alert('用户名密码不允许为空！');window.location.href='signin1.html';</script>";
	 exit;
  }
  $sql="select * from users where is_admin='1'";
  $re = mysql_query($sql);
  $user = mysql_fetch_array($re);
  if($username== $user['u_name'] && $password== $user['u_pwd'])
  {
	  setcookie("u_name",$user['u_name'],time()+3600);
	  setcookie("u_id",$user['u_id'],time()+3600);
	  echo "<script>alert('管理员登陆成功！');window.location.href='depart.php';</script>";

  }
  else
  {
	  echo "<script>alert('登陆失败，用户名或密码输入错误，请核对后输入！');window.location.href='signin1.html';</script>";
  }
  mysql_close($con);
 ?>